import Vue from "vue"
import Vuex from "vuex"
import storage from "@/uni-sub-base/utils/storage.js"
import reportModule from "./modules/report"
import tabBarModule from "./modules/tab-bar"

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        showProImg: true,
        token: "",
        cartData: [],
        tempCartData: [],
        valetCartData: [],
        isUp: "",
        isUpCartView: "",
        isUpOrderView: "",
        isUpReturnOrderView: "",
        useAddress: null,
        isUpclientView: "",
        isUpMeView: "",
        isUpVipView: "",
        //supply
        billMsg: {},
        isUpcomegoView: "",
        isUpRemarkView: "",
        isUpAddView: "",
        isUpProductView: "",
        isUpOrderAccountView: "",
        isUpMapView: "",
    },
    mutations: {
        SET_SHOW_PRO_IMG(state, isShow) {
            state.showProImg = isShow
            storage.setCache("isShowProImg", isShow)
        },
        SET_AUTH(state, token) {
            state.token = token
            storage.setCache("token", token)
        },
        CLEAR_AUTH(state) {
            state.token = ""
            storage.setCache("token", "")
        },
        SET_CART(state, cartData) {
            state.cartData = cartData
        },
        SET_TEMP_CART(state, tempCartData) {
            state.tempCartData = tempCartData
        },
        SET_VALET_CART(state, valetCartData) {
            state.valetCartData = valetCartData
        },
        UP_VIEW(state, isUp) {
            state.isUp = isUp
        },
        UP_CART_VIEW(state, isUpCartView) {
            state.isUpCartView = isUpCartView
        },
        UP_ORDER_VIEW(state, isUpOrderView) {
            state.isUpOrderView = isUpOrderView
        },
        UP_CLIENT_VIEW(state, isUpclientView) {
            state.isUpclientView = isUpclientView
        },
        UP_ME_VIEW(state, isUpMeView) {
            state.isUpMeView = isUpMeView
        },
        UP_VIP_VIEW(state, isUpVipView) {
            state.isUpVipView = isUpVipView
        },

        UP_RETURN_ORDER_VIEW(state, isUpReturnOrderView) {
            state.isUpReturnOrderView = isUpReturnOrderView
        },
        SET_USE_ADDRESS(state, useAddress) {
            state.useAddress = useAddress
        },

        SET_BILLMSG(state, billMsg) {
            state.billMsg = billMsg
        },
        UP_COMEGO_VIEW(state, isUpcomegoView) {
            state.isUpcomegoView = isUpcomegoView
        },
        UP_REMARK_VIEW(state, isUpRemarkView) {
            state.isUpRemarkView = isUpRemarkView
        },
        UP_ADDPRODUCT_VIEW(state, isUpAddView) {
            state.isUpAddView = isUpAddView
        },
        UP_PRODUCT_VIEW(state, isUpProductView) {
            state.isUpProductView = isUpProductView
        },
        UP_ACCOUNT_VIEW(state, isUpOrderAccountView) {
            state.isUpOrderAccountView = isUpOrderAccountView
        },
        UP_MAP_VIEW(state, isUpMapView) {
            state.isUpMapView = isUpMapView
        },
    },
    getters: {
        getIsShowProImg(state) {
            return state.showProImg
        },
        getToken(state) {
            return state.token
        },
        getCartData(state) {
            return state.cartData
        },
        getTempCartData(state) {
            return state.tempCartData
        },
        getValetCartData(state) {
            return state.valetCartData
        },
        getUpView(state) {
            return state.isUp
        },
        getUpCartView(state) {
            return state.isUpCartView
        },
        getUpOrderView(state) {
            return state.isUpOrderView
        },
        getUpClientView(state) {
            return state.isUpclientView
        },
        getUpMeView(state) {
            return state.isUpMeView
        },
        getUpVipView(state) {
            return state.isUpVipView
        },
        getUpReturnOrderView(state) {
            return state.isUpReturnOrderView
        },
        getUseAddress(state) {
            return state.useAddress
        },
        //supply
        getComeGo(state) {
            return state.isUpcomegoView
        },
        getUpRemarkView(state) {
            return state.isUpRemarkView
        },
        getBillMsg(state) {
            return state.billMsg
        },
        getUpAddView(state) {
            return state.isUpAddView
        },
        getUpProductView(state) {
            return state.isUpProductView
        },
        getUpOrderAccountView(state) {
            return state.isUpOrderAccountView
        },
        getUpMapView(state) {
            return state.isUpMapView
        },
    },
    actions: {
        setCartData(data) {
            state.cartData = data
        },
    },
    modules: {
        report: reportModule,
        tabBar: tabBarModule,
    },
})

export default store
